package com.hspedu.rests;

public class instanceofExercise {
    public static void main(String[] args) {
        USB[] usbs = new USB[2];
        usbs[0] = new _Camera();
        usbs[1] = new _Phone();
        for (USB usb : usbs) {
            usb.work();
            if(usb instanceof _Phone)
            {
                ((_Phone) usb).Cell();
            }
        }
    }

}

interface USB{
    void work();
}

class _Phone implements USB
{

    @Override
    public void work() {
        System.out.println("手机工作中");
    }

    public void Cell(){
        System.out.println("打电话中");
    }
}

class _Camera implements USB
{

    @Override
    public void work() {
        System.out.println("摄影机工作中");
    }
}
